import {
    isArray
} from 'lodash' ;

export default routes => processRoutes(routes);

function processRoutes(routes) {

    const processedRoutes = [];

    routes.forEach(({
                        children,
                        fullPath: path,
                        component
                    }) => {

        if (isArray(children)) {

            processedRoutes.push(...processRoutes(children));

        } else {

            processedRoutes.push({
                path,
                component
            });
        }

    });

    return processedRoutes;
}
